package com.briup.cloud.framework.logging.web.controller;

import com.briup.cloud.framework.logging.utils.annotation.LoggingAccess;
import com.briup.cloud.framework.logging.bean.BaseLogging;
import com.briup.cloud.framework.logging.service.ILoggingService;
import com.briup.cloud.framework.logging.web.vm.LogParam;
import com.briup.framework.utils.web.Response;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author guomiao
 * @Date 2022/3/4 10:27
 */
@Api(tags = "日志服务")
@LoggingAccess(value = "日志模块")
@RestController
@RequestMapping("/base/log")
public class BaseLoggingController {

    @Autowired
    private ILoggingService loggingService;

    @ApiOperation(value = "分页查找所有日志")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页码",defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",defaultValue = "10")
    })
    @LoggingAccess(value = "分页查找所有日志")
    @GetMapping("/all")
    public Response<PageInfo<BaseLogging>> allByPage(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize){
        PageInfo<BaseLogging> result = loggingService.findAllByPage(pageNum,pageSize);
        return Response.success(result);
    }

    @ApiOperation(value = "按条件分页查找所有日志")
    @LoggingAccess(value = "按条件分页查找")
    @GetMapping("/by/condition")
    public Response<PageInfo<BaseLogging>> findByCondition(LogParam logParam){
        PageInfo<BaseLogging> result = loggingService.findByCondition(logParam);
        return Response.success(result);
    }
}
